/*
 * Copyright 2004-2005 aosft
 * 本软件及其所有拷贝的名称，与光盘上或本软件中注明的公司同在。
 * 本软件及文档享有版权，并受国家版权法及国际协约条款的保护。
 * 您不可以从本软件中去掉其版权声明；并保证为本软件的拷贝（本部或部分）* 复制版权声明。
 * 您同意制止以任何形式非法拷贝本软件及文档。
 * 版权信息参见：
 *      http://www.asoft.cn/licenses
 */

package com.asoft.examonline.teach.service;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;

import com.asoft.common.base.web.service.AbstractListService;
import com.asoft.examonline.teach.manager.TeachResourceManager;
import com.asoft.examonline.teach.view.foreveryone.TeachResourceList4EveryOne;

/**
 * <p>Title: 教学资源</p>
 * <p>Description: 查询教学资源</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: aosft</p>
 * @ $Author: amon.lei $
 * @ $Date: 2005/02/16 01:04:15 $
 * @ $Revision: 1.6 $
 * @ created in 2007-5-15
 *
 */

public class FindTeachResourcesService extends AbstractListService
{
        static Logger logger = Logger.getLogger(FindTeachResourcesService.class);

        private TeachResourceManager teachResourceManager;

        public void setTeachResourceManager(TeachResourceManager teachResourceManager)
        {
                this.teachResourceManager = teachResourceManager;
        }

        /** 获取列表的models */
        public List getList(HttpServletRequest request)
        {
                // 获取翻页结果集合
                logger.debug("1. 获取查询条件.....");
                // 获取查询条件
                String domainId = this.getValueFromRequestParameter(request,"domainId");
                String subjectId = this.getValueFromRequestParameter(request,"subjectId");
                String courseId = this.getValueFromRequestParameter(request,"courseId");
                String sectionId = this.getValueFromRequestParameter(request,"sectionId");
                String unitId = this.getValueFromRequestParameter(request,"unitId");
                String knowledgePointId = this.getValueFromRequestParameter(request,"knowledgePointId");
                String knowledgeTypeId = this.getValueFromRequestParameter(request,"knowledgeTypeId");
                String difficultyId = this.getValueFromRequestParameter(request,"difficultyId");
                String publishCompanyId = this.getValueFromRequestParameter(request,"publishCompanyId");
                String keyWord = this.getValueFromRequestParameter(request,"keyWord");
                // 排序
                String orderBy = this.getValueFromRequestParameter(request,"orderBy","tr.pri");
                String sortType = this.getValueFromRequestParameter(request,"sortType","asc");
                logger.debug("2. 获取查询条件完毕,开始查询.....");
                return this.teachResourceManager.findTeachResources(domainId,
                                                                    subjectId,
                                                                    courseId,
                                                                    unitId,
                                                                    sectionId,
                                                                    knowledgePointId,
                                                                    knowledgeTypeId,
                                                                    difficultyId,
                                                                    publishCompanyId,
                                                                    keyWord,
                                                                    orderBy,
                                                                    sortType);
        }

        /** model -> viewer */
        public Object getViewer(HttpServletRequest request)
        {
                // 根据request里面提供的参数做角色、权限判断,然后返回对应的viewer
                return new TeachResourceList4EveryOne(); // foreveryone
        }
}
